﻿Imports System.ComponentModel

Public Class ViewBase
	Implements INotifyPropertyChanged

#Region "Notifiers"

	''' <summary>
	''' The property changed event.
	''' </summary>
	''' <param name="sender"></param>
	''' <param name="e"></param>
	''' <remarks></remarks>
	Public Event PropertyChanged(sender As Object, e As ComponentModel.PropertyChangedEventArgs) Implements ComponentModel.INotifyPropertyChanged.PropertyChanged

	''' <summary>
	''' Raises the PropertyChanged event.
	''' </summary>
	''' <param name="PropertyName">The name of the property to alert about.</param>
	''' <remarks></remarks>
	Protected Sub RaisePropertyChanged(PropertyName As String)
		RaiseEvent PropertyChanged(Me, New ComponentModel.PropertyChangedEventArgs(PropertyName))
	End Sub
#End Region

	''' <summary>
	''' Set the property and raise the property changed notification.
	''' </summary>
	''' <param name="Property">The name of the object that holds the property's value.</param>
	''' <param name="Value">The value to set the property to.</param>
	''' <param name="SenderName">Optional. Set to the name of the actual property, or let the compiler services detect it automatically.</param>
	''' <returns></returns>
	''' <remarks></remarks>
	Public Function SetProp(Of T)(ByRef [Property] As T, Value As T, <System.Runtime.CompilerServices.CallerMemberName> Optional SenderName As String = "") As Boolean
		If Not Object.Equals([Property], Value) Then
			[Property] = Value
			RaisePropertyChanged(SenderName)
			Return True
		Else
			Return False
		End If
	End Function



End Class
